<?php
$server = "localhost";
$user = "root";
$pwd = "root";
$database = "maxik";
//$ulinix = mysqli_connect($server, $user, $pwd, $database);
//if ($ulinix) {
//    $query = "create table maxik(id int primary key unique not null,name varchar(50) not null,password1 varchar(50) not null ,password2 varchar(50) not null ,sex int not null,tel char not null,selfintroduction varchar(300))";
//    $queryok = mysqli_query($ulinix, $query);
//    if ($queryok) {
//        echo "数据表创建成功";
//    } else {
//        echo "数据表创建失败";
//        echo mysqli_error($ulinix);
//    }
//} else {
//    echo "no";
//    echo "<br>";
//    echo mysqli_connect_error();
//}


$name = $_POST['username'];
$password1 = $_POST['pwd1'];
$password2 = $_POST['pwd2'];
$sex = $_POST['sex'];
$tel = $_POST['tel'];
$geren = $_POST['grjs'];
$hometown=$_POST['hometown'];
$hobby=$_POST['hobby'];

echo $hometown;
echo "<br>";

$xqah=implode("#",$hobby);
//print_r($xqah) ;




$ulinix = mysqli_connect($server, $user, $pwd, $database);
if ($ulinix) {
    echo "数据库连接成功";
    $query = "insert into maxik(name,password1,password2,sex,tel,selfintroduction,hometown,hobby)
 values ('" . $name . "','" . $password1 . "','" . $password2 . "'," . $sex . ",'" . $tel . "','" . $geren . "','".$hometown."','".$xqah."')";
    echo $query;
    $queryok = mysqli_query($ulinix, $query);
    if ($queryok) {
        echo "数据添加成功！";
    } else {
        echo "数据添加失败！" . mysqli_error($ulinix);
    }
} else {
    echo "数据库连接失败" . mysqli_connect_error();
}
